home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / VBSamples / DirectDraw / Tutorials / Tut5 / ddtut5.frm (.txt) next >
Encoding:
Visual Basic Form  |  2001-10-08  |  9.0 KB  |  240 lines

  1. VERSION 5.00
  2. Begin VB.Form DDDisplayCardInfo 
  3.    Caption         =   "DD Display Card Information"
  4.    ClientHeight    =   6570
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   4785
  8.    Icon            =   "ddtut5.frx":0000
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   6570
  11.    ScaleWidth      =   4785
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.ListBox OutList 
  14.       Height          =   6495
  15.       Left            =   0
  16.       TabIndex        =   0
  17.       Top             =   0
  18.       Width           =   4815
  19.    End
  20. Attribute VB_Name = "DDDisplayCardInfo"
  21. Attribute VB_GlobalNameSpace = False
  22. Attribute VB_Creatable = False
  23. Attribute VB_PredeclaredId = True
  24. Attribute VB_Exposed = False
  25. Dim m_dx As New DirectX7
  26. Private Sub Form_Load()
  27.     Me.Show
  28.     GetDisplayCards
  29. End Sub
  30. Sub GetDisplayModes(sGuid As String)
  31.     'If you want to switch display modes
  32.     'to a certain resolution
  33.     'this is how you figure out what resoultions
  34.     'are supported.
  35.     'note some cards will report zero for
  36.     'the refresh rate.
  37.     Dim DisplayModesEnum As DirectDrawEnumModes
  38.     Dim ddsd2 As DDSURFACEDESC2
  39.     Dim dd As DirectDraw7
  40.     Set dd = m_dx.DirectDrawCreate(sGuid)
  41.     dd.SetCooperativeLevel Me.hWnd, DDSCL_NORMAL
  42.     Set DisplayModesEnum = dd.GetDisplayModesEnum(0, ddsd2)
  43.     OutList.AddItem " Display Modes"
  44.     For i = 1 To DisplayModesEnum.GetCount()
  45.         DisplayModesEnum.GetItem i, ddsd2
  46.         OutList.AddItem "  Index          " + Str(i)
  47.         OutList.AddItem "  Width          " + Str(ddsd2.lWidth)
  48.         OutList.AddItem "  Height         " + Str(ddsd2.lHeight)
  49.         OutList.AddItem "  Bits Per Pixel" + Str(ddsd2.ddpfPixelFormat.lRGBBitCount)
  50.         OutList.AddItem "  Refresh Rate   " + Str(ddsd2.lRefreshRate)
  51.         OutList.AddItem ""
  52.     Next
  53.     Set dd = Nothing
  54. End Sub
  55. Sub GetDisplayCards()
  56.     'Some systems will have multiple display cards
  57.     'or have daughter cards for 3d support.
  58.     'if you want to draw to more than just the
  59.     'primary display or search for 3d hardware not
  60.     'on the primary display card you can
  61.     'use this code to search for such devices
  62.     'Note that windows 98 supports multiple monitors.
  63.     'Note the GUID is what identifies the device
  64.     'and that on the primary display this will return
  65.     'an empty string
  66.     Dim ddEnum As DirectDrawEnum
  67.     Dim strGuid As String
  68.     Set ddEnum = m_dx.GetDDEnum()
  69.     OutList.AddItem "Display Cards"
  70.     For i = 1 To ddEnum.GetCount()
  71.         
  72.         OutList.AddItem " Index        " + Str(i)
  73.         OutList.AddItem " Description  " + ddEnum.GetDescription(i)
  74.         OutList.AddItem " Name         " + ddEnum.GetName(i)
  75.         OutList.AddItem " GUID         " + ddEnum.GetGuid(i)
  76.         OutList.AddItem ""
  77.         
  78.         strGuid = ddEnum.GetGuid(i)
  79.         GetDDCaps strGuid
  80.         GetD3DDevices strGuid
  81.         GetDisplayModes strGuid
  82.         
  83.     Next
  84. End Sub
  85. Sub GetDDCaps(sGuid As String)
  86.     Dim dd As DirectDraw7
  87.     Dim hwCaps As DDCAPS   'HARDWARE
  88.     Dim helCaps As DDCAPS  'SOFTWARE EMULATION
  89.     Set dd = m_dx.DirectDrawCreate(sGuid)
  90.     dd.SetCooperativeLevel Me.hWnd, DDSCL_NORMAL
  91.     'Its always a good idea to figure out if the HW
  92.     'supports a feature
  93.     'may un supported features however are emulated via
  94.     'software but are much slower
  95.     'This code provide an example of querying the hw.
  96.     'Note there is a seperate caps call for determining
  97.     '3d capabilities
  98.     dd.GetCaps hwCaps, helCaps
  99.     'how much video memory is available
  100.     OutList.AddItem "  HW CAPS"
  101.     OutList.AddItem "   total video memory " + Str(hwCaps.lVidMemTotal)
  102.     OutList.AddItem "   free video memory " + Str(hwCaps.lVidMemFree)
  103.     'Palette Support
  104.     'Most apps dont use palettes since
  105.     'all cards support 16bpp
  106.     'Some apps use 8bpp for speed
  107.     lVal = hwCaps.lPalCaps
  108.     If (lVal = 0) Then
  109.         OutList.AddItem "   no hw palette support"
  110.     End If
  111.     If (lVal And DDPCAPS_1BIT) Then
  112.         OutList.AddItem "   palette support 1bpp "
  113.     End If
  114.     If (lVal And DDPCAPS_2BIT) Then
  115.         OutList.AddItem "   palette support 2bit "
  116.     End If
  117.     If (lVal And DDPCAPS_8BIT) Then
  118.         OutList.AddItem "   palette support 8bit "
  119.     End If
  120.     If (lVal And DDPCAPS_8BITENTRIES) Then
  121.         OutList.AddItem "   palette support 8bit entries "
  122.     End If
  123.     If (lVal And DDPCAPS_ALLOW256) Then
  124.         OutList.AddItem "   palette support setting all 256 colors"
  125.     End If
  126.     'do we support the gamma ramp interface?
  127.     lVal = hwCaps.ddsCaps.lCaps2
  128.     If lVal And DDCAPS2_CANCALIBRATEGAMMA Then
  129.         OutList.AddItem "   supports gamma correction"
  130.     Else
  131.         OutList.AddItem "   no support for gamma correction"
  132.     End If
  133.     Set dd = Nothing
  134. End Sub
  135. Sub GetD3DDevices(sGuid As String)
  136.     Dim d3denum As Direct3DEnumDevices
  137.     Dim helDesc As D3DDEVICEDESC7
  138.     Dim hwDesc As D3DDEVICEDESC7
  139.     Dim dd As DirectDraw7
  140.     Dim ddSurf As DirectDrawSurface7
  141.     Dim d3d As Direct3D7
  142.     Set dd = m_dx.DirectDrawCreate(sGuid)
  143.     Set d3d = dd.GetDirect3D()
  144.         
  145.     OutList.AddItem "   D3D devices"
  146.     'NOTE its important not to get to bogged down
  147.     'in understand the caps bits. particularly
  148.     'if using the retained mode api.
  149.     'things become more important if you want to run
  150.     'use specialized features such as blending and
  151.     'multiple texture stages
  152.     'there are cards that dont have a zbuffer
  153.     'that may need there triangles sorted..
  154.     'most cards however have zbuffers
  155.     'The color model is the most important aspect in
  156.     'determining speed. software rasterizers provide
  157.     'MONOchormatic lighting for more speed.
  158.     'The sort flags are only important of IM applications
  159.     'that need to work on HW that doesnt support z buffers
  160.     Set d3denum = d3d.GetDevicesEnum()
  161.     OutList.AddItem ""
  162.     For i = 1 To d3denum.GetCount()
  163.         
  164.         d3denum.GetDesc i, hwDesc
  165.         
  166.         
  167.         
  168.         OutList.AddItem "     Guid        " + d3denum.GetGuid(i)
  169.         OutList.AddItem "     Description " + d3denum.GetDescription(i)
  170.         OutList.AddItem "     Name        " + d3denum.GetName(i)
  171.         
  172.         ' you can make
  173.         
  174.         OutList.AddItem "    Device "
  175.         With hwDesc
  176.             OutList.AddItem "     Max Texture Height  " + Str(.lMaxTextureHeight)
  177.             OutList.AddItem "     Max Texture Width   " + Str(.lMaxTextureWidth)
  178.             
  179.                         
  180.             If (.lDeviceRenderBitDepth And DDBD_8) Then
  181.                 OutList.AddItem "     Supports rendering to 8 bit"
  182.             End If
  183.             If (.lDeviceRenderBitDepth And DDBD_16) Then
  184.                 OutList.AddItem "     Supports rendering to 16 bit"
  185.             End If
  186.             If (.lDeviceRenderBitDepth And DDBD_24) Then
  187.                 OutList.AddItem "     Supports rendering to 24 bit"
  188.             End If
  189.             If (.lDeviceRenderBitDepth And DDBD_32) Then
  190.                 OutList.AddItem "     Supports rendering to 32 bit"
  191.             End If
  192.             
  193.             
  194.             If (.lDeviceZBufferBitDepth And DDBD_8) Then
  195.                 OutList.AddItem "     Supports  8 bit z buffer"
  196.             End If
  197.             If (.lDeviceZBufferBitDepth And DDBD_16) Then
  198.                 OutList.AddItem "     Supports  16 bit z buffer"
  199.             End If
  200.             If (.lDeviceZBufferBitDepth And DDBD_24) Then
  201.                 OutList.AddItem "     Supports 24 bit z buffer"
  202.             End If
  203.             If (.lDeviceZBufferBitDepth And DDBD_32) Then
  204.                 OutList.AddItem "     Supports 32 bit z buffer"
  205.             End If
  206.             If (.lDeviceZBufferBitDepth = 0) Then
  207.                 OutList.AddItem "     no z buffer support"
  208.             End If
  209.             
  210.             If (.lDevCaps And D3DDEVCAPS_TEXTURENONLOCALVIDMEM) Then
  211.                 OutList.AddItem "     Supports AGP textures"
  212.             End If
  213.             If (.lDevCaps And D3DDEVCAPS_SORTDECREASINGZ) Then
  214.                 OutList.AddItem "     IM triangles must be sorted by decreasing depth"
  215.             End If
  216.             If (.lDevCaps And D3DDEVCAPS_SORTDECREASINGZ) Then
  217.                 OutList.AddItem "     IM triangles must be sorted exactly"
  218.             End If
  219.             If (.lDevCaps And D3DDEVCAPS_SORTINCREASINGZ) Then
  220.                 OutList.AddItem "     IM triangles must be sorted by increasing depth"
  221.             End If
  222.             
  223.             If (.lDevCaps And D3DDEVCAPS_TEXTUREVIDEOMEMORY) Then
  224.                 OutList.AddItem "     IM can uses video memory to store textures"
  225.             End If
  226.             
  227.         End With
  228.         
  229.         OutList.AddItem ""
  230.     Next
  231. End Sub
  232. Private Sub Form_Resize()
  233.     If Me.Width > 100 Then
  234.         OutList.Width = Me.Width - 100
  235.     End If
  236.     If Me.Height > 400 Then
  237.         OutList.Height = Me.Height - 400
  238.     End If
  239. End Sub
  240.